package cmd

import (
	"context"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gcmd"
)

//func handler(req *ghttp.Request) {
//	req.Response.Writeln("Hello Go 就啊哈哈~11 BindHandler")
//}

var (
	Main = gcmd.Command{
		Name:  "main",
		Usage: "main",
		Brief: "start http server",
		Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
			s := g.Server()
			// 注册路由
			//user := user.New()
			// 添加用户
			// GET:/ 指定请求方法
			//s.BindObject("/user", user.New())
			//s.BindHandler("GET:/getUser", user.GetUser)
			//s.BindHandler("POST:/addUser", user.AddUser)
			//s.BindHandler("DELETE:/delUser", user.DelUser)
			//s.BindHandler("PUT:/putUser", user.UpdateUser)
			// 路由分组
			//s.Group("/user", func(group *ghttp.RouterGroup) {
			//	group.Middleware(ghttp.MiddlewareHandlerResponse)
			//	group.Bind(user.New())
			//})
			// 路由规范：

			s.Run()
			return nil
		},
	}
)
